/**
 * @file Dart_Events.h
 * @brief 飞镖事件支持库，支持事件注册、事件触发
 * @version 1.0
 * @date 2024-03-28
 */
#pragma once
#ifndef _DART_EVENTS_H_
#define _DART_EVENTS_H_

// 飞镖事件基
#pragma once
#include "firmware.h"
#include "esp_event.h"
// #include "espnow_protocol.h"

extern esp_event_loop_handle_t dart_events_loop_handle;

ESP_EVENT_DEFINE_BASE(Dart_Events);

#pragma pack(1)

enum
{
    OTA_BEGIN_EVENT,
    OTA_COMPLETE_EVENT,
    CONFIG_EVENT,
    CONFIG_COMPLETE_EVENT,
    RESPONSE_EVENT,
    BEACON_TIMEOUT_EVENT,
};

struct OTA_BEGIN_EVENT_DATA
{
    uint8_t address = 0xFF;
    uint8_t data_len = sizeof(OTA_BEGIN_EVENT_DATA);
};
struct OTA_COMPLETE_EVENT_DATA
{
    uint8_t address = 0xFF;
    uint8_t data_len = sizeof(OTA_COMPLETE_EVENT_DATA);
    esp_err_t status;
    uint8_t ota_type; // 1 for startup ota, 0&2 for manual ota
};
struct CONFIG_EVENT_DATA // 比较浪费，但是省事
{
    uint8_t address = 0xFF;
    uint8_t data_len = sizeof(CONFIG_EVENT_DATA);
    Dart_Common_config_info_t config_common_info;
};
struct CONFIG_COMPLETE_EVENT_DATA
{
    uint8_t address = 0xFF;
    uint8_t data_len = sizeof(CONFIG_COMPLETE_EVENT_DATA);
    esp_err_t status;
};
struct RESPONSE_EVENT_DATA
{
    uint8_t address;
    uint8_t data_len = sizeof(RESPONSE_EVENT_DATA);
};
// Beacon Timeout不需要数据

#endif
